﻿//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
using NetCMS.DALFactory;
using NetCMS.Model;


namespace NetCMS.Content
{
    public class ContentManage
    {
        NetCMS.DALFactory.IContentManage dal;
        public ContentManage()
        {
            dal = DataAccess.CreateContentManage();
        }

        #region 站点列表导航

        /// <summary>
        /// 得到列表返回值
        /// </summary>
        /// <param name="ParentID"></param>
        /// <returns></returns>
        public IDataReader GetClassSitenewsstr(string ParentID, string SiteID)
        {
            return dal.GetClassSitenewsstr(ParentID, SiteID);
        }
        #endregion 站点列表导航

        #region 新闻内容管理开始
        #region 新闻内容
        /// <summary>
        /// 更新栏目状态
        /// </summary>
        /// <param name="Num">1为已生，0为未生成</param>
        public void updateClassStat(int Num, string ID, int flag)
        {
            dal.updateClassStat(Num, ID,flag);
        }

        /// <summary>
        /// 根据ID获得新闻NewsID
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public string GetNewsIDfromID1(int id)
        {
            return dal.GetNewsIDfromID1(id);
        }
        /// <summary>
        /// 新闻内容管理.得到索引表
        /// </summary>
        /// <param name="ParentID"></param>
        /// <returns></returns>
        public IDataReader GetNewsIndex()
        {
            return dal.GetNewsIndex();
        }
        /// <summary>
        /// 新闻内容管理.得到站点表
        /// </summary>
        /// <param name="ParentID"></param>
        /// <returns></returns>
        public DataTable sel_newsInfo(int flag)
        {
            DataTable dt = dal.sel_newsInfo(flag);
            return dt;
        }
   
        // by Simplt.Xie
        /// <summary>
        /// 修改新闻得到新闻属性
        /// </summary>
        /// <param name="NewsID"></param>
        /// <param name="DataLib"></param>
        /// <returns></returns>
        public IDataReader sel_NameID(string NewsID,int flag)
        {
            return dal.sel_NameID(NewsID,flag);
        }

        /// <summary>
        /// 来源入库
        /// </summary>
        /// <param name="nID"></param>
        public void iGen(string _TempStr, string _URL, string _EmailURL, int _num)
        {
            dal.iGen(_TempStr, _URL, _EmailURL, _num);
        }

        /// <summary>
        /// 判断新闻标题是否存在
        /// </summary>
        /// <param name="NewsTitle"></param>
        /// <returns></returns>
        public int newsTitletf(string NewsTitle, string dtable, string EditAction, string NewsID)
        {
            return dal.newsTitletf(NewsTitle, dtable, EditAction, NewsID);
        }

        ///// <summary>
        ///// 插入子新闻
        ///// </summary>
        ///// <param name="uc"></param>
        //public void insertSubNewsContent(string NewsID, string getNewsID, string NewsTitle, string DataLib, string TitleColor, int TitleBTF, int TitleITF, int colsNum)
        //{
        //    dal.insertSubNewsContent(NewsID, getNewsID, NewsTitle, DataLib, TitleColor, TitleBTF, TitleITF, colsNum);
        //}

        /// <summary>
        /// 插入新闻
        /// </summary>
        /// <param name="uc"></param>
        public void addUpdate_newsContent(NetCMS.Model.NewsContent uc,int flag)
        {
            dal.addUpdate_newsContent(uc,flag);
        }

        /// <summary>
        /// 插入头条
        /// </summary>
        /// <param name="uc"></param>
        public void addUpdate_TT(NetCMS.Model.NewsContentTT uc,int flag)
        {
            dal.addUpdate_TT(uc,flag);
        }

        /// <summary>
        /// 插入投票
        /// </summary>
        /// <param name="uc"></param>
        public void addUpdate_Vote(NetCMS.Model.VoteContent uc,int flag)
        {
            dal.addUpdate_Vote(uc,flag);
        }

        /// <summary>
        /// 插入附件
        /// </summary>
        /// <param name="NewsID"></param>
        /// <param name="DataLib"></param>
        /// <param name="FileURL"></param>
        /// <param name="OrderID"></param>
        public void insertFileURL(string URLName, string NewsID, string DataLib, string FileURL, int OrderID)
        {
            dal.insertFileURL(URLName, NewsID, DataLib, FileURL, OrderID);
        }

        /// <summary>
        /// 更新附件
        /// </summary>
        /// <param name="DataLib"></param>
        /// <param name="FileURL"></param>
        /// <param name="OrderID"></param>
        public void updateFileURL(string URLName, string DataLib, string FileURL, int OrderID, int ID)
        {
            dal.updateFileURL(URLName, DataLib, FileURL, OrderID, ID);
        }

        public void deleteFilesurl(int flgTF, string NewsID)
        {
            dal.deleteFilesurl(flgTF, NewsID);
        }

        /// <summary>
        /// 得到某条新闻的附件列表
        /// </summary>
        /// <param name="NewsID"></param>
        /// <param name="DataTB"></param>
        /// <returns></returns>
        public DataTable sel_infoByStr(string NewsID, string DataTB,int flag)
        {
            return dal.sel_infoByStr(NewsID, DataTB,flag);
        }

        /// <summary>
        /// 得到某一个接点是否存在
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public int getFileIDTF(int ID)
        {
            return dal.getFileIDTF(ID);
        }
        /// <summary>
        /// ajax保存新闻进临时库！返回编号
        /// </summary>
        /// <param name="Content"></param>
        /// <returns></returns>
        public string saveAjaxContent(string Content)
        {
            return dal.saveAjaxContent(Content);
        }

        /// <summary>
        /// 得到某一个新闻的头条参数
        /// </summary>
        /// <param name="NewsID"></param>
        /// <param name="DataLib"></param>
        /// <returns></returns>
        public DataTable getTopline(string NewsID, string DataLib, int NewsTFNum)
        {
            DataTable dt = dal.getTopline(NewsID, DataLib, NewsTFNum);
            return dt;
        }
        /// <summary>
        /// 得到栏目中文名称
        /// </summary>
        /// <param name="ClassID"></param>
        /// <returns></returns>
        public string sel_cName(string ClassID,int flag)
        {
            return dal.sel_cName(ClassID,flag);
        }
        #endregion 新闻内容
        #region 栏目
        /// <summary>
        /// 得到栏目信息
        /// </summary>
        /// <param name="nID"></param>
        public DataTable getClassContent(string ClassID,int flag)
        {
            DataTable dt = dal.getClassContent(ClassID,flag);
            return dt;
        }

        /// <summary>
        /// 插入栏目数据
        /// </summary>
        /// <param name="uc"></param>
        public void addUpdate_ClassContent(NetCMS.Model.ClassContent uc,int flag)
        {
            dal.addUpdate_ClassContent(uc,flag);
        }

        /// <summary>
        /// 删除栏目到回收站
        /// </summary>
        /// <param name="ClassID"></param>
        public void del_newsInfos(string ClassID,int flag)
        {
            dal.del_newsInfos(ClassID,flag);
        }
        /// <summary>
        /// 得到栏目下的子类并彻底删除
        /// </summary>
        /// <param name="ParentID"></param>
        /// <returns></returns>
        public void GetChildClassdel(string ParentID,int flag)
        {
            dal.GetChildClassdel(ParentID,flag);
        }

        /// <summary>
        /// 改变栏目状态
        /// </summary>
        /// <param name="ClassID"></param>
        /// <param name="NUM"></param>
        public void ChangeLock(string ClassID, int NUM)
        {
            dal.ChangeLock(ClassID, NUM);
        }

        /// <summary>
        /// 复位所有栏目
        /// </summary>
        public void delUpdate_newsClass(int flag)
        {
            dal.delUpdate_newsClass(flag);
        }

        /// <summary>
        /// 更新权重
        /// </summary>
        /// <param name="ParentID"></param>
        /// <returns></returns>
        public void updateOrderP(string ClassID, int OrderID)
        {
            dal.updateOrderP(ClassID, OrderID);
        }

        /// <summary>
        /// 添加单页面
        /// </summary>
        /// <param name="uc"></param>
        public void addUpdate_Page(NetCMS.Model.PageContent uc,int flag)
        {
            dal.addUpdate_Page(uc,flag);
        }
        #endregion 栏目

        #endregion 新闻内容管理结束

        #region 新闻列表
        public DataTable GetPage(string SpecialID, string Editor, string ClassID, string sKeywrd, string DdlKwdType, string sChooses, string SiteID, int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
        {
            return dal.GetPage(SpecialID, Editor, ClassID, sKeywrd, DdlKwdType, sChooses, SiteID, PageIndex, PageSize, out RecordCount, out PageCount, SqlCondition);
        }
        public void del_News(string ClassID, int flag)
        {
             dal.del_News(ClassID,flag);
        }
        public int delUpdate_news(string id,int flag)
        {
            return dal.delUpdate_news(id,flag);
        }
        public int GetClassNewsCount(string cid)
        {
            return dal.GetClassNewsCount(cid);
        }
        public string sel_path(string id,int flag)
        {
            return dal.sel_path(id,flag);
        }
        public int Update_Lock(string id, int nums)
        {
            return dal.Update_Lock(id, nums);
        }

        public void allCheck(int[] id)
        {
            dal.allCheck(id);
        }

        public IDataReader getNewsPath(string id)
        {
            return dal.getNewsPath(id);
        }
        /// <summary>
        /// 得到归档数字
        /// </summary>
        /// <param name="ClassID"></param>
        /// <returns></returns>
        public int sel_old_classInHitoryDay(string ClassID)
        {
            return dal.sel_old_classInHitoryDay(ClassID);
        }

        public int Add_old_News(string fieldnm, string id, DateTime oldtime)
        {
            return dal.Add_old_News(fieldnm, id, oldtime);
        }
        public int Add_JSFile(string JsID, string Njf_title, string NewsId, string PicPath, string ClassId, string SiteID, DateTime CreatTime, DateTime TojsTime)
        {
            return dal.Add_JSFile(JsID, Njf_title, NewsId, PicPath, ClassId, SiteID, CreatTime, TojsTime);
        }
        public int del_moveInfo(string sTb, string sOrgNews)
        {
            return dal.del_moveInfo(sTb, sOrgNews);
        }
        public string getFileNameInfo(string NewsID, string DataLib)
        {
            return dal.getFileNameInfo(NewsID, DataLib);
        }
        public void Copy_news(string ClassID, string DataLib, string sOrgNews, string sTb, string NewsID, string FileName)
        {
            dal.Copy_news(ClassID, DataLib, sOrgNews, sTb, NewsID, FileName);
        }
        public void Copy_ClassNews(string ClassID, string DataLib, string sOrgNews, string sTb, string NewsID, string FileName)
        {
            dal.Copy_ClassNews(ClassID, DataLib, sOrgNews, sTb, NewsID, FileName);
        }
        public int update_newsStrInfo(int CommTF, int DiscussTF, string NewsProperty, string Templet, int OrderID, int CommLinkTF, int Click, string FileEXName, string sTb, string sOrgNews)
        {
            return dal.update_newsStrInfo(CommTF, DiscussTF, NewsProperty, Templet, OrderID, CommLinkTF, Click, FileEXName, sTb, sOrgNews);
        }
        public int update_Info(int CommTF, int DiscussTF, string NewsProperty, string Templet, int OrderID, int CommLinkTF, int Click, string FileEXName, string sTb, string sOrgNews)
        {
            return dal.update_Info(CommTF, DiscussTF, NewsProperty, Templet, OrderID, CommLinkTF, Click, FileEXName, sTb, sOrgNews);
        }
        public void Up_Classnews(int CommTF, int DiscussTF, string NewsProperty, string Templet, int OrderID, int CommLinkTF, int Click, string FileEXName, string sTb, string ClassID, string Tags, string Souce)
        {
            dal.Up_Classnews(CommTF, DiscussTF, NewsProperty, Templet, OrderID, CommLinkTF, Click, FileEXName, sTb, ClassID, Tags, Souce);
        }
        public int Up_PicURL(string PicURL, string SPicURL, string ID, string tb)
        {
            return dal.Up_PicURL(PicURL, SPicURL, ID, tb);
        }

        public int add_newsNews(string unName, string titleCSS, string unNewsid, string NewsID, string NewsTitle, string NewsTable, string TTNewsCSS, string IsMakePic, string SiteID,int flag)
        {
            return dal.add_newsNews(unName, titleCSS, unNewsid, NewsID, NewsTitle, NewsTable, TTNewsCSS, IsMakePic, SiteID,flag);
        }
        public void upCheckStat(string getID, int levelsID)
        {
            dal.upCheckStat(getID, levelsID);
        }

        public DataTable getLockNews(string UserName)
        {
            return dal.getLockNews(UserName);
        }
        #endregion

        #region 不规则新闻
        public DataTable GetPages(int PageIndex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
        {
            return dal.GetPages(PageIndex, PageSize, out RecordCount, out PageCount, SqlCondition);
        }
        public int Str_DelSql(string UnID)
        {
            return dal.Str_DelSql(UnID);
        }

        public int Add_SubNews(string unNewsid, string Arr_OldNewsId, string NewsRow, string NewsTitle, string NewsTable, string SiteID, string titleCSS)
        {
            return dal.Add_SubNews(unNewsid, Arr_OldNewsId, NewsRow, NewsTitle, NewsTable, SiteID, titleCSS);
        }

        public DataTable GetPageiframe(string DdlClass, string sKeywrds, string sChoose, string DdlKwdType, int pageindex, int PageSize, out int RecordCount, out int PageCount, params SQLConditionInfo[] SqlCondition)
        {
            return dal.GetPageiframe(DdlClass, sKeywrds, sChoose, DdlKwdType, pageindex, PageSize, out RecordCount, out PageCount, SqlCondition);
        }
        public int Add_fieldnm(string fieldnm, string id, DateTime oldtime)
        {
            return dal.Add_fieldnm(fieldnm, id, oldtime);
        }

        public int infoIDNum(string InfoID, string APIID, string dbtable)
        {
            return dal.infoIDNum(InfoID, APIID, dbtable);
        }

        #endregion
        #region 自定义字段
        #region 修改新闻获得自定义字段

        public string modifyNewsDefineValue(string defineColumns, string NewsID, string DataLib, string DsApiID)
        {
            return dal.modifyNewsDefineValue(defineColumns, NewsID, DataLib, DsApiID);
        }

        #endregion 修改新闻获得自定义字段
        #region 插入自定义字段值

        public void addUpdate_DefineSign(string DsNewsID, string DsEName, string DsNewsTable, int DsType, string DsContent, string DsApiID,int flag)
        {
            dal.addUpdate_DefineSign(DsNewsID, DsEName, DsNewsTable, DsType, DsContent, DsApiID,flag);
        }
        #endregion 插入自定义字段值
        #endregion 自定义字段
        //#region 插入临时表
        //public void insertFormTB(string Prot, string NewsID, DateTime CreatTime, string DataTable, int NewsType, int isConstr, int MaxNumber, int updateNum, string ClassID)
        //{
        //    dal.insertFormTB(Prot, NewsID, CreatTime, DataTable, NewsType, isConstr, MaxNumber, updateNum, ClassID);
        //}
        //#endregion 插入临时表
        #region 百度新闻协议使用
        /// <summary>
        /// 清除过期的临时新闻
        /// </summary>
        public void delTBDateNumber(int dateNum)
        {
            dal.delTBDateNumber(dateNum);
        }

        public void delTBTypeNumber(int getcondition)
        {
            dal.delTBTypeNumber(getcondition);
        }

        public void delTBNewsID(string NewsID)
        {
            dal.delTBNewsID(NewsID);
        }
        #endregion 百度新闻协议

        #region 统筹
        public int getNewsRecordEdior(string UserName)
        {
            return dal.getNewsRecordEdior(UserName);
        }
        #endregion 统筹

        /// <summary>
        /// 浏览新闻获得参数
        /// </summary>
        /// <param name="NewsID"></param>
        /// <returns></returns>
        public string getnewsReview(string NewsID, string gType)
        {
            return dal.getnewsReview(NewsID, gType);
        }

        /// <summary>
        /// 得到新闻附件地址
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public string getNewsAccessory(int ID)
        {
            return dal.getNewsAccessory(ID);
        }

        /// <summary>
        /// 更新导航
        /// </summary>
        /// <param name="ClassID"></param>
        /// <returns></returns>
        public void updateReplaceNavi(string ClassID)
        {
            dal.updateReplaceNavi(ClassID);
        }

        /// <summary>
        /// 新闻统计
        /// </summary>
        /// <param name="siteid"></param>
        /// <param name="flg"></param>
        /// <returns></returns>
        public int newsstat(string siteid, string flg)
        {
            return dal.newsstat(siteid, flg);
        }

        /// <summary>
        /// 批量更新新闻属性
        /// </summary>
        /// <param name="Pro"></param>
        /// <param name="NewsID"></param>
        public void updateNewsPro(string str, string ID, int num)
        {
            dal.updateNewsPro(str, ID, num);
        }
      
        public void addSpecialTo(string NewsID, string SpecialID)
        {
            dal.addSpecialTo(NewsID, SpecialID);
        }

    }
}
